﻿//TODO: Rename in accordance with the view name when its done properly.
Hoot.Views.Account = {
    
    init: function () {
        $('#btnLogOn').click(Hoot.Views.Account.logOn);
    },

    logOn : function() {
        var data = {UserName : $('#txtUserName').val(), Password : $('#txtPassword').val()};
        var options = { data: data, success: Hoot.Views.Account.logOn_SuccessHandler };
        Hoot.Api.Account.logOn(options);
    },

    logOn_SuccessHandler : function(data) {
        alert(123);
        for (var x = 0; x <= data.Errors.length-1; x++)
        {
            alert(data.Errors[x]);
        }
        
        if (data.RedirectTo != null)
        {
            //alert(Hoot.Config.serverRootUrl);
            alert(data.RedirectTo);
             window.location.href = data.RedirectTo;
            //window.location
        }


    },
};

$(document).ready(Hoot.Views.Account.init);